package com.example.demo1.controller;

import com.example.demo1.domain.User;
import com.example.demo1.service.UserServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/user")
public class userController {
    @Autowired
    private UserServiceImpl userServiceImpl;


    @RequestMapping("/search")
    @ResponseBody
    public List<User> findUsers(){
        return userServiceImpl.findUser();
    }

    @RequestMapping
    public String userPage(Model model){
        List<User> users = userServiceImpl.findUser();
        model.addAttribute("users",users);
        return "pages/user/list.html";
    }
}
